<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>通过原型区分dom节点</title>
</head>
<body>
    <div id="app">
        <ul>
            <li><a href=""><span><div></div></span><span></span></a></li>
            <li><a href=""><span></span><span></span></a></li>
            <li><a href=""><span><div></div></span><span></span></a></li>
            <li><a href=""><span></span><span></span></a></li>
        </ul>
    </div>
    <script>
        // const div = document.querySelector('#app');
        // console.log(div.__proto__ == HTMLDivElement.prototype);
        // console.log(div instanceof HTMLDivElement);

        function getAll(el,prototype) {
            const nodes = [];
            Array.from(el.childNodes).map(node => {
                if(node.nodeType == 1) nodes.push(...(getAll(node,prototype)));
                if( node instanceof prototype ) {
                    nodes.push(node);
                }
            });
            return nodes;
        }
        console.log(getAll(document.body,HTMLDivElement));
    </script>
</body>
</html>